<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: TileMapServer.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: TileMapServer.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/*
 * @Description: In User Settings Edit
 * @Author: xiaoying
 * @Date: 2019-09-04 10:01:04
 * @LastEditTime: 2019-09-12 15:24:12
 * @LastEditors: mayuanye
 */
import { NativeModules } from 'react-native';
import MapServer from './MapServer.js';
import Dot from './Dot.js';
let TMS = NativeModules.JSTileMapServer;

/**
 * @class TileMapServer
 * @description 瓦片地图服务
 */
export default class TileMapServer extends MapServer {
  constructor() {
    super();
    Object.defineProperty(this, '_MGTileMapServerId', {
      get: function() {
        return this._MGMapServerId;
      },
      set: function(_MGTileMapServerId) {
        this._MGMapServerId = _MGTileMapServerId;
      },
    });
  }
  /**
   * 创建一个新的TileMapServer对象
   *
   * @memberof TileMapServer
   * @returns {Promise&lt;TileMapServer>}
   */
  async createObj() {
    try {
      var { TileMapServerId } = await TMS.createObj();
      var tileMapServer = new TileMapServer();
      tileMapServer._MGTileMapServerId = TileMapServerId;
      return tileMapServer;
    } catch (e) {
      console.error(e);
    }
  }

  //    /**
  //     * 获取瓦片的切片方式
  //     *
  //     * @memberof TileMapServer
  //     * @return {int} 返回瓦片的切片方式 ，例：1-TileSliceType.SliceWMTS
  //     * @description 默认为OGC_WMTS切片方式
  //     */
  //    async getTileSliceType(){
  //        try {
  //            let tileSliceType = await TMS.getTileSliceType(this._MGTileMapServerId);
  //            return tileSliceType;
  //        } catch (e) {
  //            console.error(e);
  //        }
  //    }

  /**
   * 设置最小显示缩放级
   *
   * @memberof TileMapServer
   * @param minZoom 最小显示缩放级
   * @return {Promise&lt;Void>}
   */
  async setMinZoom(minZoom) {
    try {
      await TMS.setMinZoom(this._MGTileMapServerId, minZoom);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取最小显示缩放级
   *
   * @memberof TileMapServer
   * @return {int} 最小显示缩放级
   */
  async getMinZoom() {
    try {
      let minZoom = await TMS.getMinZoom(this._MGTileMapServerId);
      return minZoom;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 设置最大显示缩放级
   *
   * @memberof TileMapServer
   * @param maxZoom 最大显示缩放级
   * @return {Promise&lt;Void>}
   */
  async setMaxZoom(maxZoom) {
    try {
      await TMS.setMaxZoom(this._MGTileMapServerId, maxZoom);
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取最大显示缩放级
   *
   * @memberof TileMapServer
   * @return {int} 最大显示缩放级
   */
  async getMaxZoom() {
    try {
      let maxZoom = await TMS.getMaxZoom(this._MGTileMapServerId);
      return maxZoom;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取服务数据源缩放级范围
   *
   * @memberof TileMapServer
   * @param {Object} minZoom 数据源最小缩放级（Object--IntUser）
   * @param {Object} maxZoom 数据源最大缩放级（Object--IntUser）
   * @returns {boolean} 成功返回true
   */
  async getZoomCapacity(minZoom, maxZoom) {
    try {
      let result = await TMS.getZoomCapacity(
        this._MGTileMapServerId,
        minZoom._MGIntUserId,
        maxZoom._MGIntUserId
      );
      return result;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取瓦片裁剪原点
   *
   * @memberof TileMapServer
   * @returns {Promise&lt;Dot>} 瓦片裁剪原点
   */
  async getTileOriginXY() {
    try {
      var { point2DId } = await TMS.getTileOriginXY(this._MGTileMapServerId);
      var dot = new Dot();
      dot._MGDotId = point2DId;
      return dot;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获得瓦片的高宽大小
   *
   * @memberof TileMapServer
   * @param {Object} width 瓦片宽（像素） （Object--IntUser）
   * @param {Object} height 瓦片高（像素）（Object--IntUser）
   * @returns {boolean} 成功返回true
   */
  async getTileSize(width, height) {
    try {
      let result = await TMS.getTileSize(
        this._MGTileMapServerId,
        width._MGIntUserId,
        height._MGIntUserId
      );
      return result;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 设置缩放级对应的瓦片分辨率（logic/pixel）
   *
   * @memberof TileMapServer
   * @param {int} zoom 瓦片缩放级
   * @param {double} dResolution dResolution 瓦片分辨率
   * @returns {int} 1-成功；0-失败
   */
  async setTileResolution(zoom, dResolution) {
    try {
      let result = await TMS.setTileResolution(
        this._MGTileMapServerId,
        zoom,
        dResolution
      );
      return result;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获得缩放级对应的瓦片分辨率(logic/pixel)
   *
   * @memberof TileMapServer
   * @param {int} zoom 瓦片缩放级
   * @returns {double} 瓦片分辨率
   */
  async getTileResolution(zoom) {
    try {
      let tileResolution = await TMS.getTileResolution(
        this._MGTileMapServerId,
        zoom
      );
      return tileResolution;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获得缩放级别对应的地面分辨率,与Y值有关（dLogY纬度）
   *
   * @memberof TileMapServer
   * @param {int} zoom 瓦片缩放级
   * @param {double} dLogY 纬度
   * @returns {double} 地面分辨率
   */
  async getGroundResolution(zoom, dLogY) {
    try {
      let groundResolution = await TMS.getGroundResolution(
        this._MGTileMapServerId,
        zoom,
        dLogY
      );
      return groundResolution;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 获取缩放级对应的比例尺
   *
   * @memberof TileMapServer
   * @param {int} zoom 瓦片缩放级
   * @param {double} dLogY 纬度
   * @returns {double} 返回比例尺
   * @description 获取比例尺=图上距离/实地距离，图上距离通过瓦片像素反算成米，实地距离通过地球半径与纬度计算
   */
  async getScale(zoom, dLogY) {
    try {
      let scale = await TMS.getScale(this._MGTileMapServerId, zoom, dLogY);
      return scale;
    } catch (e) {
      console.error(e);
    }
  }

  //    /**
  //     * 获得缩放级别对应的有效瓦片矩阵行列值
  //     *
  //     * @memberof TileMapServer
  //     * @param {int} zoom 缩放级
  //     * @param {Object} topRow 上（起始）行号
  //     * @param {Object} leftCol 左（起始）列号
  //     * @param {Object} bottomRow 下（终止）行号
  //     * @param {Object} rightCol 右（终止）列号
  //     * @returns {boolean} 成功返回true
  //     */
  //    async getTileMatrix(zoom, topRow, leftCol, bottomRow, rightCol){
  //        try {
  //            let result = await TMS.getTileMatrix(this._MGTileMapServerId, zoom, topRow._MGIntUserId, leftCol._MGIntUserId, bottomRow._MGIntUserId, rightCol._MGIntUserId);
  //            return result ;
  //        } catch (e) {
  //            console.error(e);
  //        }
  //    }

  /**
   * 根据URL获取瓦片图像
   *
   * @memberof TileMapServer
   * @param {String} strURL 瓦片图像的URL
   * @returns {Array} 瓦片图像数据 （int类型的数组）
   */
  async getTileImageByURL(strURL) {
    try {
      let array = await TMS.getTileImageByURL(this._MGTileMapServerId, strURL);
      return array;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 根据行列号、缩放级获取瓦片图像
   *
   * @memberof TileMapServer
   * @param {int} row 瓦片行索引
   * @param {int} col 瓦片列索引
   * @param {int} zoom 瓦片缩放级
   * @returns {Array} 瓦片图像数据 （int类型的数组）
   */
  async getTileImage(row, col, zoom) {
    try {
      let array = await TMS.getTileImage(
        this._MGTileMapServerId,
        row,
        col,
        zoom
      );
      return array;
    } catch (e) {
      console.error(e);
    }
  }

  /**
   * 释放瓦片图像数据
   *
   * @memberof TileMapServer
   * @param {Array} buf 瓦片图像数据
   * @returns {boolean} 成功返回true
   */
  async freeTileImage(buf) {
    try {
      let result = await TMS.freeTileImage(this._MGTileMapServerId, buf);
      return result;
    } catch (e) {
      console.error(e);
    }
  }
}
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnnClsInfo.html">AnnClsInfo</a></li><li><a href="AnnInfo.html">AnnInfo</a></li><li><a href="Annotation.html">Annotation</a></li><li><a href="AnnotationCls.html">AnnotationCls</a></li><li><a href="AnnotationsOverlay.html">AnnotationsOverlay</a></li><li><a href="AnnotationView.html">AnnotationView</a></li><li><a href="BasCls.html">BasCls</a></li><li><a href="ClassItemValue.html">ClassItemValue</a></li><li><a href="CoordinateConvert.html">CoordinateConvert</a></li><li><a href="CoordinateConvertParameter.html">CoordinateConvertParameter</a></li><li><a href="CrossData.html">CrossData</a></li><li><a href="DataBase.html">DataBase</a></li><li><a href="DataBaseSync.html">DataBaseSync</a></li><li><a href="Document.html">Document</a></li><li><a href="DocumentItem.html">DocumentItem</a></li><li><a href="Dot.html">Dot</a></li><li><a href="Dot3D.html">Dot3D</a></li><li><a href="Dots.html">Dots</a></li><li><a href="Dots3D.html">Dots3D</a></li><li><a href="DownloadDataBaseParmeters.html">DownloadDataBaseParmeters</a></li><li><a href="DownloadLayerOption.html">DownloadLayerOption</a></li><li><a href="ElpParam.html">ElpParam</a></li><li><a href="ElpTransformation.html">ElpTransformation</a></li><li><a href="ElpTransParam.html">ElpTransParam</a></li><li><a href="Environment.html">Environment</a></li><li><a href="ExtField.html">ExtField</a></li><li><a href="FClsInfo.html">FClsInfo</a></li><li><a href="Feature.html">Feature</a></li><li><a href="FeatureEdit.html">FeatureEdit</a></li><li><a href="FeaturePagedResult.html">FeaturePagedResult</a></li><li><a href="FeatureQuery.html">FeatureQuery</a></li><li><a href="FeatureSync.html">FeatureSync</a></li><li><a href="Field.html">Field</a></li><li><a href="Fields.html">Fields</a></li><li><a href="FillStyle.html">FillStyle</a></li><li><a href="GeneralVectorLabel.html">GeneralVectorLabel</a></li><li><a href="GeoAnno.html">GeoAnno</a></li><li><a href="GeoLine.html">GeoLine</a></li><li><a href="GeoLines.html">GeoLines</a></li><li><a href="Geometry.html">Geometry</a></li><li><a href="GeometryExp.html">GeometryExp</a></li><li><a href="GeometryParams.html">GeometryParams</a></li><li><a href="GeomInfo.html">GeomInfo</a></li><li><a href="GeoPoints.html">GeoPoints</a></li><li><a href="GeoPolygon.html">GeoPolygon</a></li><li><a href="GeoPolygons.html">GeoPolygons</a></li><li><a href="GeoVarLine.html">GeoVarLine</a></li><li><a href="Graphic.html">Graphic</a></li><li><a href="GraphicCircle.html">GraphicCircle</a></li><li><a href="GraphicHeatmap.html">GraphicHeatmap</a></li><li><a href="GraphicImage.html">GraphicImage</a></li><li><a href="GraphicMultiPoint.html">GraphicMultiPoint</a></li><li><a href="GraphicPoint.html">GraphicPoint</a></li><li><a href="GraphicPolygon.html">GraphicPolygon</a></li><li><a href="GraphicPolylin.html">GraphicPolylin</a></li><li><a href="GraphicsOverlay.html">GraphicsOverlay</a></li><li><a href="GraphicsOverlays.html">GraphicsOverlays</a></li><li><a href="GraphicStippleLine.html">GraphicStippleLine</a></li><li><a href="GraphicText.html">GraphicText</a></li><li><a href="GroupLayer.html">GroupLayer</a></li><li><a href="HeatmapPoint.html">HeatmapPoint</a></li><li><a href="Image.html">Image</a></li><li><a href="IntUser.html">IntUser</a></li><li><a href="Label.html">Label</a></li><li><a href="LabelInfo.html">LabelInfo</a></li><li><a href="LatLng.html">LatLng</a></li><li><a href="LayerEnum.html">LayerEnum</a></li><li><a href="LinePlaceInfo.html">LinePlaceInfo</a></li><li><a href="LineStyle.html">LineStyle</a></li><li><a href="LinInfo.html">LinInfo</a></li><li><a href="MagnifierOption.html">MagnifierOption</a></li><li><a href="Map.html">Map</a></li><li><a href="MapLayer.html">MapLayer</a></li><li><a href="MapPosition.html">MapPosition</a></li><li><a href="Maps.html">Maps</a></li><li><a href="MapServer.html">MapServer</a></li><li><a href="MapServiceInfo.html">MapServiceInfo</a></li><li><a href="MapServiceLayerInfo.html">MapServiceLayerInfo</a></li><li><a href="MapView.html">MapView</a></li><li><a href="MeasureContentWillChangeListener.html">MeasureContentWillChangeListener</a></li><li><a href="MeasureOption.html">MeasureOption</a></li><li><a href="Model.html">Model</a></li><li><a href="ModelsOverlay.html">ModelsOverlay</a></li><li><a href="MultiClassTheme.html">MultiClassTheme</a></li><li><a href="MultiClassThemeInfo.html">MultiClassThemeInfo</a></li><li><a href="OGCWMTSMapServer.html">OGCWMTSMapServer</a></li><li><a href="PntInfo.html">PntInfo</a></li><li><a href="PointF.html">PointF</a></li><li><a href="PointPlaceInfo.html">PointPlaceInfo</a></li><li><a href="PointStyle.html">PointStyle</a></li><li><a href="QueryBound.html">QueryBound</a></li><li><a href="QueryDef.html">QueryDef</a></li><li><a href="RangeTheme.html">RangeTheme</a></li><li><a href="RangeThemeInfo.html">RangeThemeInfo</a></li><li><a href="Record.html">Record</a></li><li><a href="RecordSet.html">RecordSet</a></li><li><a href="Rect.html">Rect</a></li><li><a href="RegInfo.html">RegInfo</a></li><li><a href="RegionPlaceInfo.html">RegionPlaceInfo</a></li><li><a href="ServerLayer.html">ServerLayer</a></li><li><a href="SFeatureCls.html">SFeatureCls</a></li><li><a href="SimpleLabel.html">SimpleLabel</a></li><li><a href="SimpleModelLayer.html">SimpleModelLayer</a></li><li><a href="SimpleModelLayerUtil.html">SimpleModelLayerUtil</a></li><li><a href="SimpleTheme.html">SimpleTheme</a></li><li><a href="SketchEditor.html">SketchEditor</a></li><li><a href="SketchStyle.html">SketchStyle</a></li><li><a href="SnappingOption.html">SnappingOption</a></li><li><a href="SpaAnalysis.html">SpaAnalysis</a></li><li><a href="SpaCalculator.html">SpaCalculator</a></li><li><a href="SpaProjection.html">SpaProjection</a></li><li><a href="SpaRelation.html">SpaRelation</a></li><li><a href="SRefData.html">SRefData</a></li><li><a href="SyncBase.html">SyncBase</a></li><li><a href="SyncDataBaseParmeters.html">SyncDataBaseParmeters</a></li><li><a href="SyncLayerOption.html">SyncLayerOption</a></li><li><a href="TextAnnInfo.html">TextAnnInfo</a></li><li><a href="TextAnno.html">TextAnno</a></li><li><a href="TextStyle.html">TextStyle</a></li><li><a href="Theme.html">Theme</a></li><li><a href="ThemeInfo.html">ThemeInfo</a></li><li><a href="Themes.html">Themes</a></li><li><a href="TileMapServer.html">TileMapServer</a></li><li><a href="UniqueTheme.html">UniqueTheme</a></li><li><a href="UniqueThemeInfo.html">UniqueThemeInfo</a></li><li><a href="VectorCls.html">VectorCls</a></li><li><a href="VectorLabel.html">VectorLabel</a></li><li><a href="VectorLayer.html">VectorLayer</a></li><li><a href="VectorMapServer.html">VectorMapServer</a></li><li><a href="VectorTheme.html">VectorTheme</a></li><li><a href="VectorTileMapServer.html">VectorTileMapServer</a></li><li><a href="VisualMap.html">VisualMap</a></li><li><a href="XClsInfo.html">XClsInfo</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addAnnotation">addAnnotation</a></li><li><a href="global.html#addAnnotations">addAnnotations</a></li><li><a href="global.html#animatePosition">animatePosition</a></li><li><a href="global.html#distanceOfGeometry">distanceOfGeometry</a></li><li><a href="global.html#getAllAnnotations">getAllAnnotations</a></li><li><a href="global.html#getAnnotation">getAnnotation</a></li><li><a href="global.html#getAnnotationCount">getAnnotationCount</a></li><li><a href="global.html#getGeometryByType">getGeometryByType</a></li><li><a href="global.html#indexOf">indexOf</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#moveAnnotation">moveAnnotation</a></li><li><a href="global.html#removeAllAnnotations">removeAllAnnotations</a></li><li><a href="global.html#removeAnnotation">removeAnnotation</a></li><li><a href="global.html#removeAnnotationByIndex">removeAnnotationByIndex</a></li><li><a href="global.html#removeAnnotations">removeAnnotations</a></li><li><a href="global.html#requestAuthorization">requestAuthorization</a></li><li><a href="global.html#setResolution">setResolution</a></li><li><a href="global.html#setScale">setScale</a></li><li><a href="global.html#setSize">setSize</a></li><li><a href="global.html#setSystemLibraryPath">setSystemLibraryPath</a></li><li><a href="global.html#toGeometry">toGeometry</a></li><li><a href="global.html#toGeometrys">toGeometrys</a></li><li><a href="global.html#toGraphicsFromGeometry">toGraphicsFromGeometry</a></li><li><a href="global.html#updatePositionbyViewPoint">updatePositionbyViewPoint</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Fri Jan 17 2020 16:23:46 GMT+0800 (GMT+08:00)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
